﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace NIP.Speech.Dialog.States
{
    public class QueryDialogState : DialogStateBase, IDialogState 
    {
        public QueryDialogState()
            : base(DialogStateType.QueryDialogState)
        {
            
        }

        new public bool PreConditionCheck()
        {
            return true;
        }

        new public EventArgs.StateStatusEventArgs VoiceCommandResponse(Dictionary<string, string> recognizedText)
        {
            var args = new EventArgs.StateStatusEventArgs();
            if(recognizedText.ContainsKey("yes"))
            {
                args.nextState = Responder.StateCreator(DefaultNextState);
                para.configCommand.Remove("if_no");
                args.nextState.para.inputCommand = para.configCommand;
                args.Type = EventArgs.StateStatusEventTypes.NONE;
                return args;
            }
            if (recognizedText.ContainsKey("no"))
            {
                args.nextState = Responder.StateCreator(DefaultAbortNextState);
                para.configCommand.Remove("if_yes");
                args.nextState.para.inputCommand = para.configCommand;
                args.Type = EventArgs.StateStatusEventTypes.NONE;
                return args;
            }

            //not yes or no, ask again
            args.Type = EventArgs.StateStatusEventTypes.SPEAK_ONLY;
            args.ToSpeak = DefaultSpeechResponse;
            return args;
        }
    }
}
